<template>
  <el-container class="home-container">
    <!-- 头部 -->
    <el-header>
      <router-link style="text-decoration: none" to="/home/welcom">
        <div>
          <img src="@/assets/image/heima.png" alt="">
          <span>黑马电商后台管理系统</span>
        </div>
      </router-link>

      <el-button type="info" @click="outLogin">退出</el-button>
    </el-header>
    <!-- 主体 -->
    <el-container>
      <!-- 侧边栏 -->
      <Aside :menuList="menuList"></Aside>
      <!-- 右侧主体 -->
      <el-main>
        <router-view></router-view>
        <!-- <home-right></home-right> -->
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import Aside from '@/comment/AsideList.vue'
// import { getMenusAPI } from '@/api/homeAPI.js'
// import HomeRight from '@/comment/HomeRight.vue'

export default {
  components: { Aside },
  name: 'Home',
  data() {
    return {
      menuList: []
    }
  },
  methods: {
    outLogin() {
      localStorage.removeItem('token')
      this.$router.push('/login')
    }
  },
  async created() {
    const { data: res } = await this.$api.home.getMenusAPI()
    if (res.meta.status !== 200) return this.$message.error('请求数据失败')

    this.menuList = res.data
    console.log(res)
  }
}
</script>

<style lang="less" scoped>
.home-container {
  height: 100%;

  .el-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background-color: #363d40;
    padding-left: 0;
    div {
      display: flex;
      align-items: center;
      span {
        margin-left: 15px;
        color: #fff;
        font-size: 20px;
      }
    }
  }

  .el-aside {
    background-color: #313743;
  }
  .el-main {
    background-color: #e9edf1;
  }
}
</style>
